define(
		[ "PDAppDir/properties", "CkPlayer", "PDUtilDir/util", "PDUtilDir/slidebar",
				"PDUtilDir/inputSelect",
				"PDUtilDir/fileupload/singleFileUpload",
				"css!AppPathDir/account/accountInfos/views/css/css" ],
		function(Properties, CkPlayer, Util, Slidebar, inputSelect, MFU) {
			function updateSupportInit($scope, $compile) {
				return new updateSupport($scope, $compile);
			}
			function updateSupport($scope, $compile) {
				this.entity = new Array();
				this.cache = {
					products: new Array()
//					products: [{
//						dictCode: "产品A",
//						dictName: "产品A"
//					},{
//						dictCode: "产品B",
//						dictName: "产品B"
//					}]
				};
				this.$scope = $scope;
				this.$compile = $compile;
			}
			updateSupport.fn = updateSupport.prototype;
			updateSupport.fn.run = function(data) {
				var _this = this;
				_this.entity = $.extend({
					videos: {
						key: data.name,
						resouceId: data.uploadId,
						path: Properties.URL_FILE_SERVER_URL + data.videoPath
					}
				},data);
//				_this.entity = {
//					productId: "9063616d010e40089fb5e41d34414846",
//					productName: "asdfasdf",
//					videoIntroduce: "dddd",
//					videos: {
//						key: "a.png",
//						resouceId: "aaa",
//						path: Properties.URL_FILE_SERVER_URL + "http://www.baidu.com"
//					}
//				};
				
				this.slidebars = Slidebar({
					size : 'lg',
					url : getServer()
							+ "/static/app/video/videoInfos/views/update.html",
//					close : true,
					$scope : this.$scope,
					$compile : this.$compile,
					afterLoad : function($Panel) {
						_this.initialization();
					}
				});
			};
			updateSupport.fn.initialization = function() {
				var _this = this;
				// 初始化支付类型下拉框
				if(this.cache.products.length > 0){
					inputSelect.dropCache();
					inputSelect({
						id : "productName",
						key : {
							id : "id",
							name : "name",
							data : "data",
						},
						data : _this.cache.products,
						initData: [_this.entity.productId],
						simpleData : true,
						searchAble : false,
						callback : function(id) {
							_this.entity.productId = id[0];
						}
					});
				}else{
					$.ajax({
						url : getServer() + "/flea/hclv/product/findByDeptIdForSelect.htmls",
						success : function(data) {
                            if (data.status != 200) {
                                return;
                            }
							_this.cache.products = data.data;
							inputSelect.dropCache();
							inputSelect({
								id : "productName",
								key : {
									id : "id",
									name : "name",
									data : "data",
								},
								data : _this.cache.products,
								initData: [_this.entity.productId],
								simpleData : true,
								searchAble : false,
								callback : function(id) {
									_this.entity.productId = id[0];
								}
							});
						}
					});
				}
				MFU.init({
	                placeAt:"video_upload",
	                allowDelete:true,
	                allowMC:true,
	                onUploadSuccess:function(file){
	                	_this.entity.videos = {'key':file.name, 'resouceId':file.swordFileId,'path':file.swordFilePath};
	                },
	                onFileQueued: function(file){
	                	this.webUploader.upload();
	                }
	            });
				
				function loadedHandler() {
					// console.info('加载已完成')
				}
				var playswf = getStaticPath() + "/modules/ckplayer6.7/ckplayer/ckplayer.swf",
					flashvars = {
						f : 'http://movie.ks.js.cn/flv/other/1_0.flv',
						c : 0,
						e : 0,
						h : 4,
						my_url : encodeURIComponent(window.location.href),
						my_title : encodeURIComponent(document.title),
						loaded : 'loadedHandler',
						b : 0
					},
					params = {
						bgcolor : '#FFF',
						allowFullScreen : true,
						allowScriptAccess : 'always',
						wmode : 'transparent'
					}
//					video = [ 'http://movie.ks.js.cn/flv/other/1_0.mp4->video/mp4' ];
					video = [ _this.entity.videos.path ];
				CKobject.embed(playswf, 'video_play', 'ckplayer_a1', '604px', '504px', true, flashvars, video, params);
			};
			updateSupport.fn.save = function() {
				var _this = this;
				$.ajax({
					url : getServer() + "/flea/hclv/video/training/update.htmls",
					data : {
						'model' : JSON.stringify(_this.entity)
					},
					success : function(data) {
                        if (data.status != 200) {
                            return;
                        }
						_this.$scope.grid.refresh();
						Util.alert(data.message);
						_this.slidebars.close();
					}
				});
			};
			return updateSupportInit;
		});